#ifndef AER_TIMER_HPP_
#define AER_TIMER_HPP_

#include "aerDefs.hpp"


namespace aer {


/// ===============================
///
/// + Compute time in millisecond +
///
/// ===============================
class Timer
{
  private:
    bool m_bEnable;
    
    double m_startTime;
    double m_frameTime;
    double m_elapsedTime;    
    double m_lastFPSTime;
    
    U32 m_currentFPS;
    U32 m_frameCount;
    U32 m_totalFrameCount;//
    //U32 m_FPSLimit;
  
  
  public:  
    explicit Timer(bool bEnable=false);
    
    /** Start the timer */
    void start();
    
    /** Update per-frame time values */
    void update();
        
    /** Get time from the system */
    double getAbsoluteTime() const;
    
    
    /** Get time from the start of the timer */
    double getRelativeTime()  const { return getAbsoluteTime() - m_startTime; }
    
    /** Get the frame start time (from the start of the timer) */
    double getFrameTime()  const  { return m_frameTime; }
    
    /** Get time beetween two calls of update */
    double getElapsedTime() const { return m_elapsedTime; }
    
    /** Get current Frame Per Second */
    U32 getFPS()        { return m_currentFPS; }

    /** Get total frame count */
    U32 getTotalFrameCount() { return m_totalFrameCount; }
    

    void toggle() { m_bEnable = !m_bEnable; }
    bool isEnable() { return m_bEnable; }


  private:
    DISALLOW_COPY_AND_ASSIGN(Timer);
};

} // aer

#endif // AER_TIMER_HPP_
